package com.gemptc.yueban.daoImp;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.gemptc.daoimp.SelectImp;
import com.gemptc.utils.DBUtil;
import com.gemptc.yueban.dao.IInsertRegistration;


public class InsertRegistrationImp implements IInsertRegistration {
	Connection connection = DBUtil.getConnection();
	PreparedStatement preparedStatement = null;

	@Override
	public boolean InsertRegistration(int user_id, int ac_id,
			int rl_number,String rl_phone, String rl_message) {
	/*	int id = new SelectImp().SelectUserId(user_name);
		System.out.println(id);*/
		boolean b = false;
		String sql = "INSERT INTO registration_list(user_id,ac_id,rl_number,rl_phone,rl_message) VALUES(?,?,?,?,?)";
		try {
			preparedStatement = connection.prepareStatement(sql);
			preparedStatement.setInt(1, user_id);
			preparedStatement.setInt(2, ac_id);
			preparedStatement.setInt(3, rl_number);
			preparedStatement.setString(4, rl_phone);
			preparedStatement.setString(5, rl_message);
			preparedStatement.execute();
			b = true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			DBUtil.release(null, preparedStatement, connection);
		}
		return b;
	}

}
